ti.menu = {
	root: null,
	context: null,
	newItem: function(title, context, handler) {
		this.root = chrome.contextMenus.create({
			"title": title,
			"contexts": context,
			"onclick": handler
		});
		this.context = context;
	},
	addItem: function(title, handler) {
		if (!this.root) { ti.alert('Add Menu Item', 'No parent item defined'); return; }
		return chrome.contextMenus.create({
			"title": title,
			"contexts": this.context,
			"parentId": this.root,
			"onclick": handler
		});
	},
	addCheckBox: function(title, checked) {
		return this.insertChoice(title, 'checkbox', checked);
	},
	addRadioButton: function(title, checked) {
		return this.insertChoice(title, 'radio', checked);
	},
	addChoice: function(title, type, checked) {
		return chrome.contextMenus.create({
			"type": type,
			"title": title,
			"checked": (checked),
			"contexts": this.context,
			"parentId": this.root,
		});
	},
	addSeparator: function() {
		chrome.contextMenus.create({
			"type": "separator",
			"contexts": this.context,
			"parentId": this.root
		});
	}
}